package main

import "fmt"

type IBuilder interface {
	//这三个步骤是由指挥者来组合的
	BuildPartA() string
	BuildPartB() string
	GetProduct() Product//最终吐出一个产品
}

type Product struct {
}

type Worker struct {
}

func (w *Worker) BuildPartA() string {
	fmt.Println("build part A")
	return "build part A"
}

func (w *Worker) BuildPartB() string {
	fmt.Println("build part B")
	return "build part B"
}
func (w *Worker) GetProduct() Product {
	return Product{}
}

//指挥者
type Director struct {
	Builder IBuilder
}

func (d *Director) BuildSomething() Product {
	d.Builder.BuildPartA()
	d.Builder.BuildPartB()
	return d.Builder.GetProduct()
}
func main() {
	b := &Worker{}
	d := Director{
		Builder: b,
	}
	p := d.BuildSomething()
	fmt.Println("get product", p)
}
